package com.ws.base.db.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.ws.base.common.WSAppLogger;

public class PropertiesUtils {
    WSAppLogger logger = new WSAppLogger(PropertiesUtils.class);

    private Properties prop = null;

    private File file;

    public PropertiesUtils() {
    }

    public PropertiesUtils(File file) {
        this.file = file;
        loadProperties();
    }

    public void loadProperties() {
        InputStream is = null;

        try {
            is = new FileInputStream(file);
            if (prop == null) {
                prop = new Properties();
            }

            prop.load(is);

            if (is != null) {
                is.close();
            }
        } catch (IOException e) {
            logger.error(e, "open Properties error");
        }
    }

    public String getPropertiesValue(String key) {
        return prop.getProperty(key);
    }

    public File getFileP() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

}
